package com.java.service;

import com.java.dao.LackMapper2;
import com.java.pojo.EnterGood;
import com.java.pojo.Lack;
import com.java.pojo.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LackServiceImpl implements LackService {

    @Autowired
    private LackMapper2 lackMapper2;


    @Override
    public int addLack2(Lack lack) {
        return lackMapper2.addLack2(lack);
    }

    @Override
    public List<Lack> getListByLack2() {
        return lackMapper2.getListByLack2();
    }



    @Override
    public Page<Lack> getPageByPage(Integer a, String goodname3) {
        int b=4;//显示条数
        Page<Lack> page=new Page<>();
        page.setCurryPage(a);//设置当前页码
        page.setRows(b);//设置每页显示的条数
        Integer count = lackMapper2.getCount(goodname3);//总条数
        page.setTotalCount(count);//总条数
        int start=(a-1)*b;/*开始的索引*/
        List<Lack> list = lackMapper2.getListLack(start, b, goodname3);
        page.setList(list);/*赋值list*/
        int totalPae=count % b==0 ? count / b : (count / b)+1;
        page.setTotalPae(totalPae);/*设置总页数*/
        if(page==null){
            page=null;
        }
        return page;
    }

    @Override
    public Integer getCount(String goodname3) {
        return lackMapper2.getCount(goodname3);
    }

    @Override
    public int updLack(String id) {
        return lackMapper2.updLack(id);
    }

    @Override
    public int del(String id) {
        return lackMapper2.del(id);
    }

    @Override
    public int findSum() {
        return lackMapper2.findSum();
    }


    @Override
    public int findSum2() {
        return lackMapper2.findSum2();
    }

    @Override
    public List<Lack> getLackListByOKAndGS(Integer goodstyle3) {
        return lackMapper2.getLackListByOKAndGS(goodstyle3);
    }

    @Override
    public int updOKandNo4(String goodname) {
        return lackMapper2.updOKandNo4(goodname);
    }

    @Override
    public Lack getLackByName(String name) {
        return lackMapper2.getLackByName(name);
    }
}
